﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;

namespace DataModel
{
    public class Address
    {
        [Column("ID")]
        public int ID { get; set; }
        [Column("STREET")]
        public string Street { get; set; }
        [Column("HOUSENUMBER")]
        public string Housenumber { get; set; }
        [Column("ZIP")]
        public string ZIP { get; set; }
        [Column("CITY")]
        public string City { get; set; }

        public virtual List<Person> Persons { get; set; }
    }

    public class AddressConfiguration : EntityTypeConfiguration<Address>
    {
        public AddressConfiguration()
        {
            HasKey(x => x.ID);
            Property(x => x.ID).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
            HasMany(x => x.Persons);
            ToTable("ADDRESS");
        }
    }
}
